package com.dorm.cj.join;

import java.util.concurrent.TimeUnit;

public class JoinMain {


    public static void main(String[] args) throws InterruptedException {
        Thread th1=new Thread(()->{
            System.out.println("this is th1");
        });

        Thread th2=new Thread(()->{
            System.out.println("this is th2 start");
            try {
                TimeUnit.SECONDS.sleep(2L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("this is th2 end");
        });
        th2.start();
        th2.join();//没有此方法，main不会阻塞，，th1会先输出，有此方法，必须等th2执行完毕才会执行th1
        th1.start();
    }
}
